﻿#region Copyright ©2008-2009, Technische Universitaet Muenchen
// ====================================================================================================
//
// Last Changed by       $Author: kalus $
// Last Changed Date     $LastChangedDate: 2009-06-18 17:18:03 +0200 (Thu, 18 Jun 2009) $
// Last Changed Revision $Rev: 213 $
//
// ====================================================================================================
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace Tum.CollabXT
{
    /// <summary>
    /// Base interface for all dependencies.
    /// </summary>
    public interface IProcessElementDependency
    {
        /// <summary>
        /// Id of the dependency.
        /// </summary>
        string Id
        {
            get;
            set;
        }

        /// <summary>
        /// Name of the dependency.
        /// </summary>
        string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Storage for content of any type.
        /// To be used for internal temporary variables or as way to pass information from one tool provider to another.
        /// Additionally, data can be stored that is not recognized by all providers, but by some.
        /// </summary>
        Dictionary<string, object> ExtendedData
        {
            get;
        }
    }

    /// <summary>
    /// Base class for all dependencies.
    /// </summary>
    public abstract class Dependency : IProcessElementDependency
    {
        private string _Id;
        private string _Name;
        private string _Description;
        Dictionary<string, object> _ExtendedData = new Dictionary<string,object>();

        #region IProcessElementDependency Members

        /// <summary>
        /// Id of the dependency.
        /// </summary>
         public string Id
        {
            get { return _Id; }
            set { _Id = value; }
        }

         /// <summary>
         /// Name of the dependency.
         /// </summary>
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }

        /// <summary>
        /// Description of the dependency.
        /// </summary>
        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }

        /// <summary>
        /// Storage for content of any type.
        /// To be used for internal temporary variables or as way to pass information from one tool provider to another.
        /// Additionally, data can be stored that is not recognized by all providers, but by some.
        /// </summary>
        public Dictionary<string, object> ExtendedData
        {
            get { return _ExtendedData; }
        }
        #endregion
    }


    /// <summary>
    /// Dependency between a product and a participating role.
    /// </summary>
    public class RoleToProductDependency : Dependency
    {
        /// <summary>
        /// Id of the participating role.
        /// </summary>
        public string RoleId
        {
            get { return _RoleId; }
            set { _RoleId = value; }
        }
        private string _RoleId;

        /// <summary>
        /// Id of the product.
        /// </summary>
        public string ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }
        private string _ProductId;

        /// <summary>
        /// Constructor.
        /// </summary>
        public RoleToProductDependency()
        { }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="roleId">Id of the participating role.</param>
        /// <param name="productId">Id of the product.</param>
        public RoleToProductDependency(string roleId, string productId)
        {
            this._RoleId = roleId;
            this._ProductId = productId;
        }
    }

    /// <summary>
    /// Dependency between a product and a role responsible for it.
    /// </summary>
    public class RoleResponsibleForProductDependency : RoleToProductDependency
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public RoleResponsibleForProductDependency()
            : base()
        { }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="roleId">Id of the role responsible for the product.</param>
        /// <param name="productId">Id of the product.</param>
        public RoleResponsibleForProductDependency(string roleId, string productId)
            : base(roleId, productId)
        { }
    }

    /// <summary>
    /// Dependency between a product and a role responsible for it.
    /// </summary>
    public class RoleParticipatingInProductDependency : RoleToProductDependency
    {
       /// <summary>
       /// Constructor.
       /// </summary>
       public RoleParticipatingInProductDependency()
          : base()
       { }

       /// <summary>
       /// Constructor.
       /// </summary>
       /// <param name="roleId">Id of the role responsible for the product.</param>
       /// <param name="productId">Id of the product.</param>
       public RoleParticipatingInProductDependency(string roleId, string productId)
          : base(roleId, productId)
       { }
    }

    /// <summary>
    /// Dependency between a milestone and a belonging product.
    /// </summary>
    public class ProductMilestoneDependency : Dependency
    {
        /// <summary>
        /// Id of the product.
        /// </summary>
        public string ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }
        private string _ProductId;

        /// <summary>
        /// If of the milestone.
        /// </summary>
        public string MilestoneId
        {
            get { return _MilestoneId; }
            set { _MilestoneId = value; }
        }
        private string _MilestoneId;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the product.</param>
        /// <param name="milestoneId">Id of the milestone.</param>
        public ProductMilestoneDependency(string productId, string milestoneId)
        {
            this._ProductId = productId;
            this._MilestoneId = milestoneId;
        }
    }

    /// <summary>
    /// Dependency between a product and a belonging activity.
    /// </summary>
    public class ProductActivityDependency : Dependency
    {
        /// <summary>
        /// Id of the product.
        /// </summary>
        public string ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }
        private string _ProductId;

        /// <summary>
        /// Id of the activity.
        /// </summary>
        public string ActivityId
        {
            get { return _ActivityId; }
            set { _ActivityId = value; }
        }
        private string _ActivityId;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the product.</param>
        /// <param name="activityId">Id of the activity.</param>
        public ProductActivityDependency(string productId, string activityId)
        {
            this._ProductId = productId;
            this._ActivityId = activityId;
        }
    }


    /// <summary>
    /// Defines a product to product dependency
    /// </summary>
    public class ProductToProductDependency : Dependency
    {
        /// <summary>
        /// Id of the "main" product.
        /// </summary>
        public string ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }
        private string _ProductId;

        /// <summary>
        /// Id of the dependent product.
        /// </summary>
        public string DependentProductId
        {
            get { return _DependentProductId; }
            set { _DependentProductId = value; }
        }
        private string _DependentProductId;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the "main" product.</param>
        /// <param name="dependentProductId">Id of the dependent product.</param>
        public ProductToProductDependency(string productId, string dependentProductId)
        {
            this._ProductId = productId;
            this._DependentProductId = dependentProductId;
        }
    }

    /// <summary>
    /// Dependency between a product and another that is contextually dependent.
    /// </summary>
    public class ProductContentDependency : ProductToProductDependency
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the "main" product.</param>
        /// <param name="dependentProductId">Id of the contextually dependent product.</param>
        public ProductContentDependency(string productId, string dependentProductId)
            : base(productId, dependentProductId)
        { }
    }

    /// <summary>
    /// Dependency between a product and another one of which the generation is depending on the first.
    /// </summary>
    public class GeneratingProductDependency : ProductToProductDependency
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the "main" product.</param>
        /// <param name="dependentProductId">Id of the product having a generation depending on the "main" product.</param>
        public GeneratingProductDependency(string productId, string dependentProductId)
            : base(productId, dependentProductId)
        { }
    }

    /// <summary>
    /// Dependency between a product and another that is a part of the first.
    /// </summary>
    public class ProductCompositionDependency : ProductToProductDependency
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the "main" product.</param>
        /// <param name="dependentProductId">Id of the product that is a part of the "main" product.</param>
        public ProductCompositionDependency(string productId, string dependentProductId)
            : base(productId, dependentProductId)
        {
            ///TODO: Load ProductCompositionDependency in V-Modell XT provider
        }
    }

    /// <summary>
    /// Dependency between a product and a topic.
    /// </summary>
    public class ProductTopicDependency : Dependency
    {
        /// <summary>
        /// Id of the product.
        /// </summary>
        public string ProductId
        {
            get { return _ProductId; }
            set { _ProductId = value; }
        }
        private string _ProductId;

        /// <summary>
        /// Id of the topic.
        /// </summary>
        public string TopicId
        {
            get { return _TopicId; }
            set { _TopicId = value; }
        }
        private string _TopicId;

        /// <summary>
        /// Gets or sets the order position of this topic dependency.
        /// This applies to situations where more than one topic is referenced and an order is to be maintained.
        /// </summary>
        public int Order
        {
            get { return _Order; }
            set { _Order = value; }
        }
        private int _Order;

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="productId">Id of the product.</param>
        /// <param name="topicId">Id of the topic.</param>
        /// <param name="order">Order value of the topic. Used to keep multiple topics belonging to one product in order.</param>
        public ProductTopicDependency(string productId, string topicId, int order)
        {
            this.ProductId = productId;
            this.TopicId = topicId;
            this.Order = order;
        }
    }
}